<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property int $user_id 
 * @property int $goods_id 
 * @property bool $status
 * @property int $fav_time 
 */
class UserFav extends Model
{
    public $timestamps = false;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user_fav';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'user_id' => 'integer', 'goods_id' => 'integer', 'status' => 'integer', 'fav_time' => 'integer'];

    /**
     * 隐藏字段
     *
     * @var array
     */
    protected $hidden = ['goods_id'];

    /**
     * 商品关联
     *
     * @return \Hyperf\Database\Model\Relations\BelongsTo
     */
    public function goods()
    {
        return $this->belongsTo(Goods::class, 'goods_id', 'id');
    }

    /**
     * 商品收藏关联
     *
     * @return \Hyperf\Database\Model\Relations\HasMany
     */
    public function goodsFav()
    {
        return $this->hasMany(self::class, 'goods_id', 'goods_id');
    }
}